package com.smart.car.record.controller;

import com.alibaba.fastjson.JSONObject;
import com.smart.car.common.res.bean.ResponseResult;
import com.smart.car.common.res.exception.BusinessException;
import com.smart.car.record.entity.RecordExport;
import com.smart.car.record.service.RecordExportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * TODO 车辆离场控制
 * @author: zoutao
 * @date: 2021-05-07
 */
@Slf4j
@RestController
@RequestMapping("export")
public class RecordExportController {

    @Autowired
    private RecordExportService existsService;

    /**
     * TODO 车辆离开业务
     * {"brakeId":"9527","id":"100","plateNum":"AAAAAA"}
     * @author zoutao.blog.csdn.net
     * @param json
     * @return result
     */
    @PostMapping("/create")
    public ResponseResult<Integer> create(@RequestBody String json) throws BusinessException {
        ResponseResult<Integer> result = new ResponseResult<>();
        int rtn = existsService.createExsits(json);
        result.setCode(200);
        result.setData(rtn);
        result.setMsg("车辆出库成功");
        return result;
    }

    public static void main(String[] args) {
        RecordExport Leave = new RecordExport();
        Leave.setPlateNum("AAAAAA");
        Leave.setBrakeId("9527");
        Leave.setId("100");
        log.info(JSONObject.toJSONString(Leave));
    }

}
